package org.graduation.recruitment.entity.enums;

import jakarta.annotation.Nullable;

import java.util.List;
import java.util.Map;

public enum EducationLevel {
    PRIMARY_SCHOOL("小学"),
    MIDDLE_SCHOOL("初中"),
    HIGH_SCHOOL("高中"),
    COLLEGE("专科"),
    UNDERGRADUATE("本科"),
    GRADUATE("硕士"),
    DOCTORATE("博士");

    private final String description;

    EducationLevel(String description) {
        this.description = description;
    }

    @Nullable
    public static EducationLevel of(String description) {
        for (EducationLevel educationLevel : EducationLevel.values()) {
            if (educationLevel.getDescription().equals(description)) {
                return educationLevel;
            }
        }
        return null;
    }

    public static List<Map<EducationLevel, String>> toList() {
        return List.of(
                Map.of(EducationLevel.PRIMARY_SCHOOL, EducationLevel.PRIMARY_SCHOOL.toString()),
                Map.of(EducationLevel.MIDDLE_SCHOOL, EducationLevel.MIDDLE_SCHOOL.toString()),
                Map.of(EducationLevel.HIGH_SCHOOL, EducationLevel.HIGH_SCHOOL.toString()),
                Map.of(EducationLevel.COLLEGE, EducationLevel.COLLEGE.toString()),
                Map.of(EducationLevel.UNDERGRADUATE, EducationLevel.UNDERGRADUATE.toString()),
                Map.of(EducationLevel.GRADUATE, EducationLevel.GRADUATE.toString()),
                Map.of(EducationLevel.DOCTORATE, EducationLevel.DOCTORATE.toString())
        );
    }

    public static Map<EducationLevel, String> toMap() {
        return Map.of(
                EducationLevel.PRIMARY_SCHOOL, EducationLevel.PRIMARY_SCHOOL.toString(),
                EducationLevel.MIDDLE_SCHOOL, EducationLevel.MIDDLE_SCHOOL.toString(),
                EducationLevel.HIGH_SCHOOL, EducationLevel.HIGH_SCHOOL.toString(),
                EducationLevel.COLLEGE, EducationLevel.COLLEGE.toString(),
                EducationLevel.UNDERGRADUATE, EducationLevel.UNDERGRADUATE.toString(),
                EducationLevel.GRADUATE, EducationLevel.GRADUATE.toString(),
                EducationLevel.DOCTORATE, EducationLevel.DOCTORATE.toString()
        );
    }

    public String getDescription() {
        return description;
    }

    public String toString() {
        return getDescription();
    }
}
